CC := mpigxx

# CPPFLAGS := -I /home/rime/git/eigen -lopenblas -lblas -lpthread -fopenmp -mavx2 -march=native -std=c++14 -O3 -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -Wall
# CPPFLAGS := -qopenmp -fopenmp -mavx2 -march=native -std=c++14 -O3 -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -Wall

# CPPFLAGS := -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic -fopenmp -mavx -mavx2 -mfma -std=c++14 -O3 -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -Wall $(shell mpic++ -showme:compile) $(shell mpic++ -showme:link) # -Bstatic -lmvec -lm

CPPFLAGS := -L/public1/soft/glibc/2.23/lib -Wl,--rpath=/public1/soft/glibc/2.23/lib -Wl,--dynamic-linker=/public1/soft/glibc/2.23/lib/ld-linux-x86-64.so.2 -lmvec -lstdc++ -fopenmp -mavx -mavx2 -mfma -std=c++14 -O3 -Wno-unused-result \
			-Wno-unused-variable -Wno-unused-but-set-variable -Wall

# CPPFLAGS := -fopenmp -mavx -mavx2 -mfma -std=c++14 -O3 -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -Wall # -Bstatic -lmvec -lm
# CPPFLAGS := -fopenmp -mavx -mavx2 -mfma -std=c++14 -O3 -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -Wall # -Bstatic -lmvec -lm
# CPPFLAGS := -qopenmp -mavx -mavx2 -mfma -std=c++14 -O3 -Wno-unused-result -Wno-unused-variable -Wno-unused-but-set-variable -Wall # -Bstatic -lmvec -lm

TARGET := SLIC.out
CPP_SRCS := SLIC.cpp SLIC_slave.cpp utils.cpp
CPP_OBJS := $(CPP_SRCS:.cpp=.o)
# LINK_OBJS := libmvec.so
ASM_OBJS := $(CPP_SRCS:.cpp=.s)
CLEAN_OBJS += $(TARGET) $(CPP_OBJS) $(ASM_OBJS)

all: $(TARGET)

# $(TARGET): $(CPP_OBJS)
# 	$(CC) $(CPP_OBJS) $(LINK_OBJS) $(CPPFLAGS) $(INCLUDES)  -o $@

$(TARGET): $(CPP_SRCS)
	$(CC) $(CPP_SRCS) $(LINK_OBJS) $(CPPFLAGS) $(INCLUDES)  -o $@

$(CPP_OBJS): %.o: %.cpp
	$(CC) $< $(CPPFLAGS) $(INCLUDES) -c -o $@
	$(CC) $< $(CPPFLAGS) $(INCLUDES) -c -S

run:
	srun -p amd_256 -N 1 $(TARGET)

mpirun:
	mpirun.openmpi -np 2 $(TARGET)

clean:
	rm -f $(CLEAN_OBJS)
	rm -f *.o *.out
